package com.oa.modules.approvalsec1.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.oa.modules.approvalsec1.entity.ImageEntity;
import com.oa.modules.approvalsec1.service.ImageService;
import com.oa.modules.sys.controller.AbstractController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.oa.common.utils.PageUtils;
import com.oa.common.utils.R;



/**
 *
 *
 * @author jiangwei
 * @email 785297226@qq.com
 * @date 2021-12-13 14:19:02
 */
@RestController
@RequestMapping("image")
@Api(tags = "项目微信端轮播图相关接口")
public class PImageController extends AbstractController {
    @Autowired
    private ImageService imageService;

    /**
     * 列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "列表")
//    @RequiresPermissions("generator:image:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = imageService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
//    @RequiresPermissions("generator:image:info")
    @ApiOperation(value = "信息")
    public R info(@PathVariable("id") Integer id){
		ImageEntity image = imageService.getById(id);
        return R.ok().put("image", image);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation(value = "保存")
    @RequiresPermissions("generator:image:save")
    public R save(@RequestBody ImageEntity image){ ;
		imageService.save(image);
        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperation(value = "修改")
    @RequiresPermissions("generator:image:update")
    public R update(@RequestBody ImageEntity image){
		imageService.updateById(image);
        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    @ApiOperation(value = "删除")
    @RequiresPermissions("generator:image:delete")
    public R delete(@RequestBody Integer[] ids){
		imageService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }
    @GetMapping("get")
    @ApiOperation(value = "查询")
    public R getImage(){
        List<ImageEntity> entityList = imageService.list();
        return R.ok().put("project",entityList);
    }
}
